package com.bw.shopping.bind;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.databinding.BindingAdapter;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bw.mvvm.network.load.LoadImage;
import com.bw.shopping.R;
import com.chad.library.adapter.base.BaseQuickAdapter;


public class SeckillParticulaesBind {

    @BindingAdapter(value = {"adapter","image","value","money"})
    public static void seckillParticulaesBind(RecyclerView recyclerView,
                                              BaseQuickAdapter adapter,
                                              String imag,
                                              String value,
                                              String money){
        View headView = LayoutInflater.from(recyclerView.getContext()).inflate(R.layout.values_seckill_particulars,null);
        ImageView view = headView.findViewById(R.id.seckill_particulars_imag);
        LoadImage.loadMatchImg(imag,view);
        TextView tv = headView.findViewById(R.id.seckill_particulaes_value);
        tv.setText(value);
        TextView mn = headView.findViewById(R.id.seckill_particulaes_money);
        mn.setTextColor(Color.RED);
        mn.setText(money);
        LinearLayoutManager manager = new LinearLayoutManager(recyclerView.getContext());
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        adapter.addHeaderView(headView);
        recyclerView.setLayoutManager(manager);
        recyclerView.setAdapter(adapter);
    }
}
